//
//  OEM2ViewController.m
//  X-Touch2
//
//  Created by shengchao yang on 12-4-24.
//  Copyright (c) 2012年 foxhis. All rights reserved.
//

#import "OEM2ViewController.h"
#import "Imports1.h"

@interface OEM2ViewController ()
- (void) add1fingerTap;
- (void) closeOEM;
@end

@implementation OEM2ViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

    }
    return self;
}
- (void) checkCloseOEM{
    MyNSLog(@"in checkCloseOEM");
    if (self.view.superview) {
        MyNSLog(@"oemview's superview is not nil!");
        [self closeOEM];
    }else{
        MyNSLog(@"oemview's superview is nill");
    }
}

#pragma mark - GestureRecognizer
- (void) add1fingerTap{//手指单击
	UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
    recognizer.numberOfTouchesRequired = 1;//多少根手指
    recognizer.numberOfTapsRequired = 1;//点击几次
	[self.view addGestureRecognizer:recognizer];
	[recognizer release];	
}
- (void) handleTapFrom:(UITapGestureRecognizer *)recognizer {
    MyNSLog(@"in handleTapFrom");
    if (AppSession.isAnimating) {
        MyNSLog(@"上一个动画还未完成...");
        return;
    }
    AppSession.isAnimating = YES;
    [AppSession playMusic:VoiceFile(@"clicked.caf")];
    [self closeOEM];
}
- (void) closeOEM{
    MyNSLog(@"MenuBookChoose will be added");
    NSDictionary *infos = [NSDictionary dictionaryWithObjectsAndKeys:@"OEMViewController", @"FromNibName", @"MenuBookChoose",@"ToNibName",nil];    
    postNWithInfos(SysMsg_RootView_ControllerChange, self, infos);
}
#pragma mark - View lifecycle
- (void)viewDidLoad{
    UIImageView * imageV = (UIImageView *)[self.view viewWithTag:TagOfUIImageView+1];
    imageV.image = [FileManager getImage:@"oem.png" type:2 withRect:imageV.frame];
    [self performSelector:@selector(checkCloseOEM) withObject:nil afterDelay:3];
//    [self add1fingerTap];
    [super viewDidLoad];
}

- (void)viewDidUnload{
    [super viewDidUnload];
}
-(void) dealloc{
    MyNSLog(@"OEMViewController is deallocing");
    [super dealloc];
}
- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

@end
